////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                                                                            //
//                                                         WNProject                                                          //
//                                                                                                                            //
//            This file is distributed under the BSD 2-Clause open source license. See License.txt for details.               //
//                                                                                                                            //
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#ifndef __WN_FRUSTUM_H__
#define __WN_FRUSTUM_H__

#include "WNCore/inc/WNBase.h"
#include "WNMath/inc/WNPlane.h"
#include "WNMath/inc/WNMatrix44.h"
#include "WNMath/inc/WNPoint3.h"

namespace WNMath {
    namespace WNFrustumFOV {
        enum HORIZONTAL {
            HORIZONTAL_FOV
        };

        enum VERTICAL {
            VERTICAL_FOV
        };
    };

    class WNBox;
    class WNSphere;
    class WNBounds3;

    class WNFrustum {
    public:
        explicit WNFrustum(const WNMatrix44& _transform, WN_FLOAT32 _near, WN_FLOAT32 _far, WN_FLOAT32 _aspect, WN_FLOAT32 _fov, WNFrustumFOV::HORIZONTAL _horizontal);
        explicit WNFrustum(const WNMatrix44& _transform, WN_FLOAT32 _near, WN_FLOAT32 _far, WN_FLOAT32 _aspect, WN_FLOAT32 _fov, WNFrustumFOV::VERTICAL _vertical);
        explicit WNFrustum(WN_FLOAT32 _near, WN_FLOAT32 _far, WN_FLOAT32 _fov, WN_FLOAT32 _aspect, WNFrustumFOV::HORIZONTAL _horizontal);
        explicit WNFrustum(WN_FLOAT32 _near, WN_FLOAT32 _far, WN_FLOAT32 _fov, WN_FLOAT32 _aspect, WNFrustumFOV::VERTICAL _vertical);

        WN_VOID Transform(const WNMatrix44& _updateTransform);
        WN_VOID SetTransform(const WNMatrix44& _setTransform);

        WN_BOOL Intersects(const WNBox& _box) const;
        WN_BOOL Intersects(const WNSphere& _sphere) const;
        WN_BOOL Intersects(const WNBounds3& _bounds) const;

    public:
        WNPoint3 points[8];
        WNMatrix44 transform;
        WN_FLOAT32 nearPlane;
        WN_FLOAT32 farPlane;
        WN_FLOAT32 hFOV;
        WN_FLOAT32 vFOV;
    };
}

#endif // __WN_FRUSTUM_H__